package com.datarfid.schedule_android;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.GridView;

import com.datarfid.schedule_android.model.Schedule;
import com.datarfid.schedule_android.view.GridViewDateAdapter;
import com.datarfid.schedule_android.view.ListViewForScrollView;
import com.datarfid.schedule_android.view.ListViewNumberAdapter;
import com.datarfid.schedule_android.view.ScheduleView;

public class MainActivity extends AppCompatActivity {

    //课程表视图
    private ScheduleView scheduleQueryScheduleView;

    //表行 0-23
    private ListViewForScrollView scheduleQueryListViewNumber;

    //表头 周一到周天
    private GridView scheduleQueryGridViewDate;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_schedule);

        //隐藏标题栏
        if (getSupportActionBar() != null) {
            getSupportActionBar().hide();
        }

        initUI();
        loadData();
    }


    private void initUI() {

        scheduleQueryScheduleView = findViewById(R.id.scheduleQueryScheduleView);
        scheduleQueryListViewNumber = findViewById(R.id.scheduleQueryListViewNumber);
        scheduleQueryListViewNumber.setAdapter(new ListViewNumberAdapter(this));
        scheduleQueryGridViewDate = findViewById(R.id.scheduleQueryGridViewDate);
        scheduleQueryGridViewDate.setAdapter(new GridViewDateAdapter(this));
    }


    private void loadData() {


        scheduleQueryScheduleView.addToList(new Schedule(48, "Access\n00:00 - 23:59",
                "#e67e22", 0, 0));

        scheduleQueryScheduleView.addToList(new Schedule(48, "Secure\n00:00 - 23:59",
                "#e74c3c", 0, 1));


        scheduleQueryScheduleView.addToList(new Schedule(48, "Supervised\n00:00 - 23:59",
                "#3498db", 0, 2));

        scheduleQueryScheduleView.addToList(new Schedule(48, "Free Access\n00:00 - 23:59",
                "#2ecc71", 0, 3));


        scheduleQueryScheduleView.addToList(new Schedule(48, "Locked\n00:00 - 23:59",
                "#8e44ad", 0, 4));

        scheduleQueryScheduleView.addToList(new Schedule(48, "Access\n00:00 - 23:59",
                "#e67e22", 0, 5));

        scheduleQueryScheduleView.addToList(new Schedule(48, "Access\n00:00 - 23:59",
                "#e67e22", 0, 6));
    }


}
